import { Config } from "./Config.js";
import { Layers } from "./Layers.js";
import { Strings } from "./Strings.js";

export class Editor {
    constructor() {
        var Signal = signals.Signal;

        this.config = new Config();
        this.strings = new Strings(this.config);
        // 工具栏状态
        this.state = 'move';
        this.layers = new Layers();
        // 视图状态
        this.viewGrid = true;
        this.viewRule = true;
        this.viewZoom = 1;
        // 
        this.signals = {
            objectChanged: new Signal(),
            objectSelected: new Signal(),
        }
    }
    setState(state) {
        if (!['move', 'shape', 'pen', 'text', 'hand'].includes(state)) {
            throw new TypeError('设置的状态不正确!');
        }
        this.state = state;
        this.onStateChange && this.onStateChange(state);
    }
    publish() {
        console.log('发布');
    }
    fromJSON() {

    }
    clear() {
        this.layers.clear()
    }

}